package com.crscd.ai.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 10/9/25 5:03 PM
 * @modifiedBy:
 * @version: 1.0
 */
@Slf4j
@RestController
public class McpClientController {
  @Autowired private ChatClient chatClient;
  @Autowired private ChatModel chatModel;

  @GetMapping("/mcpclient/chat")
  public Flux<String> chat(@RequestParam(name = "msg", defaultValue = "北京") String msg) {
    log.info("使用了mcp");
    return chatClient.prompt(msg).stream().content();
  }

  @GetMapping("/mcpclient/chat2")
  public Flux<String> chat2(@RequestParam(name = "msg", defaultValue = "北京") String msg) {
    log.info("未使用mcp");
    return chatModel.stream(msg);
  }
}
